package com.wgc.canal.listener;

import com.alibaba.fastjson.JSON;
import com.alibaba.otter.canal.protocol.CanalEntry;
import com.wgc.canal.config.RabbitConfig;
import com.xpand.starter.canal.annotation.CanalEventListener;
import com.xpand.starter.canal.annotation.ListenPoint;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;

@CanalEventListener //声明当前的类是canal的监听类
public class AdUpdate {
    @Autowired
    private RestTemplate  restTemplate;
    @Autowired
    private RabbitTemplate rabbitTemplate;
    /**
     *
     * @param eventType 当前操作数据库的类型
     * @param rowData 当前操作数据库的数据
     */
    @ListenPoint(schema = "itbuka_system",table = "ad")
    public void adUpdate(CanalEntry.EventType eventType, CanalEntry.RowData rowData){
        rabbitTemplate.convertAndSend(RabbitConfig.RABBIT_EXCHANGE,RabbitConfig.RABBIT_QUEUE, JSON.toJSONString("message"));
    }
}



